﻿using _EF扩展方法.Model;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;

namespace _EF扩展方法
{
    public class BaseContext : DbContext
    {
        public BaseContext() : base("name=Default")
        {

        }

        public BaseContext(string conn) : base(conn)
        {

        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }

        public DbSet<Person> Person { get; set; }


        public int ExtendSql(string strSql, params object[] param)
        {
            return this.Database.ExecuteSqlCommand(strSql, param);
        }



        public List<T> ExtendSql<T>(string strSql, params object[] param)
        {
            return this.Database.SqlQuery<T>(strSql, param).ToList();
        }

    }
}
